<template>
  <div>
    <DoctorHeader titleText="检验申请"></DoctorHeader>
    <el-divider />
    <div class="wy-filter">
      <el-input placeholder="请输入病历号" v-model="query.caseNumber"></el-input>
      <el-input placeholder="请输入患者姓名" v-model="query.realName"></el-input>
      <el-button type="primary" @click="getTableData">搜索</el-button>
    </div>
    <el-table :data="tableData">
      <el-table-column width="80px" label="患者姓名" prop="register.realName"></el-table-column>
      <el-table-column label="患者生日" prop="register.birthday"></el-table-column>
      <el-table-column width="80px" label="患者性别" prop="register.gender"></el-table-column>
      <el-table-column label="病历号" prop="register.caseNumber"></el-table-column>
      <el-table-column show-overflow-tooltip label="检验项目" prop="medicalTechnology.techName"></el-table-column>
      <el-table-column width="220px">
        <template #default="scope">
          <el-button type="primary" size="small" plain @click="resultAdd(scope.row.id)">进行检验</el-button>
          <el-button type="danger" size="small">跳过</el-button>
          <el-button type="warning" size="small">叫号</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog
        width="600px"
        :close-on-click-modal="false"
        v-model="dialog.show"
        title="录入检验结果"
        @close="close">
      <el-input type="textarea" :rows="5" v-model="result.text"></el-input>
      <el-button type="primary" style="margin-top: 20px;" @click="save">保存</el-button>
    </el-dialog>
  </div>
</template>

<script setup>
import DoctorHeader from '@/components/doctor/header'
import { reactive, ref } from 'vue'
import { get, post } from '@/util/axios'
const query = reactive({
  caseNumber: '',
  realName: '',
  checkState: '已缴费'
})
const dialog = reactive({
  show: false
})
const tableData = ref([])
const result = reactive({
  id: null,
  text: ''
})
getTableData()
function getTableData () {
  get('/inspectionRequest/jiaofeiList', query, content => {
    tableData.value = content
  })
}
function resultAdd (id) {
  dialog.show = true
  result.id = id
}
function close () {
  dialog.show = false
  result.text = ''
}
function save () {
  post('/inspectionRequest/addResult', result, content => {
    window.location.href = window.location.href
  })
}
</script>

<style lang="scss" scoped>
</style>
